package com.hgkj.cloud.base.service.impl;

import com.hgkj.cloud.base.common.ExecutorUtils;
import com.hgkj.cloud.base.common.PageInfo;
import com.hgkj.cloud.base.dao.SysTableBriefMapper;
import com.hgkj.cloud.base.domain.SysTableBrief;
import com.hgkj.cloud.base.service.SysTableBriefService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class SysTableBriefServiceImpl implements SysTableBriefService {

    @Autowired
    private SysTableBriefMapper sysTableBriefMapper;

    @Override
    public int deleteByPrimaryKey(String uuid) {
        return sysTableBriefMapper.deleteByPrimaryKey(uuid);
    }

    @Override
    public int insert(SysTableBrief record) {
        return sysTableBriefMapper.insert(record);
    }

    @Override
    public int insertSelective(SysTableBrief record) {
        return sysTableBriefMapper.insertSelective(record);
    }

    @Override
    public SysTableBrief selectByPrimaryKey(String uuid) {
        return sysTableBriefMapper.selectByPrimaryKey(uuid);
    }

    @Override
    public int updateByPrimaryKeySelective(SysTableBrief record) {
        return sysTableBriefMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(SysTableBrief record) {
        return sysTableBriefMapper.updateByPrimaryKey(record);
    }

    @Override
    public SysTableBrief getTableInfo(Map<String, Object> map) {
        return sysTableBriefMapper.getTableInfo(map);
    }

    @Override
    public List<SysTableBrief> listTableTypes(PageInfo pi, Map<String, Object> map) {
        if(pi != null){
            map.put("currentCount", pi.getCurrentCount());
            map.put("pageSize", pi.getPageSize());
        }
        return sysTableBriefMapper.listTableTypes(map);
    }

    @Override
    public SysTableBrief listAllTableByname(String tableName) {
        return sysTableBriefMapper.listAllTableByname(tableName);
    }

    @Override
    public List<SysTableBrief> listAllTables(PageInfo pi, Map<String, Object> map) {
        if(pi != null){
            map.put("currentCount", pi.getCurrentCount());
            map.put("pageSize", pi.getPageSize());
        }
        return sysTableBriefMapper.listAllTables(map);
    }

    @Override
    public Long findAllTablesCount(Map<String, Object> map) {
        return sysTableBriefMapper.findAllTablesCount(map);
    }

    @Override
    public SysTableBrief findTableByUuid(String uuid) {
        return sysTableBriefMapper.findTableByUuid(uuid);
    }

    @Override
    public List<SysTableBrief> findTaskTables(Map<String, Object> map) {
        return sysTableBriefMapper.findTaskTables(map);
    }

    @Override
    public Long findTaskTablesCount(Map<String, Object> map) {
        return sysTableBriefMapper.findTaskTablesCount(map);
    }

    @Override
    public List<SysTableBrief> findByChineseList() {
        return sysTableBriefMapper.findByChineseList();
    }

    @Override
    public List<Map<String, Object>> findTableAllInfosByTableUuid(String TableUuid) {
        return sysTableBriefMapper.findTableAllInfosByTableUuid( TableUuid);
    }

    @Override
    public String saveExecutor(String content) {
        try {
            return ExecutorUtils.executor(content);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}
